//
//  NotesViewController.m
//  SmartLife
//
//  Created by Lawrence on 15/10/23.
//  Copyright © 2015年 Lawrence. All rights reserved.
//

#import "NotesViewController.h"
#import "NotesTableViewCellController.h"


@interface NotesViewController ()<UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate>

@property(nonatomic,strong) NSDictionary *notesDict;

@property(nonatomic,strong) UITableView *tableView;
@property(nonatomic,strong) UISearchBar *searchBar;


@end

@implementation NotesViewController
@synthesize tableView,searchBar;
-(instancetype)init{
    if (self=[super init]) {
        //[self initTableView];
    }
    return self;
}
-(instancetype)initNotesData:(NSDictionary *)dict{
    if (self=[super init]) {
        self.notesDict=dict;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initTableView];
    [self initSearchBar];
    [self registerCellNib];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark 加载xib文件
-(void)registerCellNib{
    UINib *nib=[UINib nibWithNibName:@"NotesTableViewCell"  bundle:nil];
    
    [self.tableView registerNib:nib forCellReuseIdentifier:@"NotesCell"];
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NotesTableViewCellController *cell=[self.tableView dequeueReusableCellWithIdentifier:@"NotesCell"];
    cell.labTitle.text=NSLocalizedString(@"test",nil);
    cell.labSubtitle.text=NSLocalizedString(@"test",nil);
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50.0f;
}

-(void)initTableView{
    self.tableView=[[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    [self.view addSubview:self.tableView];
}

-(void)initSearchBar{
    
    UISearchBar *tempSearchbar=[[UISearchBar alloc] initWithFrame:CGRectMake(0,0,self.tableView.frame.size.width,60)];
    tempSearchbar.placeholder=NSLocalizedString(@"快速搜索关键字", nil);
    self.searchBar=tempSearchbar;
    self.searchBar.delegate=self;
    //[self.searchBar sizeToFit];
    self.tableView.tableHeaderView=self.searchBar;
    
}

@end
